//
//  BySureCancelView.m
//  caipiao_ios
//
//  Created by mc on 2018/7/21.
//  Copyright © 2018年 ZhangZhanbin. All rights reserved.
//

#import "BySureCancelView.h"

@implementation BySureCancelView

- (id)init{
    self = [super init];
    if (self) {
        
        self.backgroundColor = BY_BACKGROUND_COLOR;
        
        UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:sureBtn];
        
        UIButton *cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:cancelBtn];
        
        [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-20);
            make.bottom.equalTo(self).offset(-10);
            make.top.equalTo(self).offset(10);
            make.left.equalTo(cancelBtn.mas_right).offset(40);
            make.width.equalTo(cancelBtn);
        }];
        
        [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(20);
            make.bottom.equalTo(self).offset(-10);
            make.top.equalTo(self).offset(10);
            make.right.equalTo(cancelBtn.mas_left).offset(40);
            make.width.equalTo(cancelBtn);
        }];
        
        sureBtn.backgroundColor = BY_THEME_COLOR;
        [sureBtn setTitle:@"确定" forState:UIControlStateNormal];
        [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        sureBtn.titleLabel.font = FONT(14);
        sureBtn.layer.cornerRadius = 5;
        sureBtn.tag = 100;
        
        [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
        [cancelBtn setTitleColor:BY_TEXT_COLOR forState:UIControlStateNormal];
        cancelBtn.titleLabel.font = FONT(14);
        cancelBtn.layer.borderColor = BY_TEXT_COLOR.CGColor;
        cancelBtn.layer.borderWidth = 1;
        cancelBtn.layer.cornerRadius = 5;
        cancelBtn.tag = 200;
        [sureBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        [cancelBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

- (void)btnAction:(UIButton *)btn{
    if (btn.tag == 100) {
        if (self.sureBlock) {
            self.sureBlock();
        }
    }else{
        if (self.cancelBlock) {
            self.cancelBlock();
        }
    }
}


@end
